package ai.spatial;

public class Vector {

	private double x;
	private double y;
	
	public Vector(double x, double y) {
		this.x = x;
		this.y = y;
	}
	
	public void setX(double x) {
		this.x = x;
	}

	public void setY(double y) {
		this.y = y;
	}
	
	public double getX() {
		return this.x;
	}
	public double getY() {
		return this.y;
	}
	
	public Vector add(Vector v2){
		return new Vector(this.x+v2.getX(), this.y+v2.getY());
	}
	
	public Vector multiply(double multiplier){
		return new Vector(this.getX()*multiplier, this.getY()*multiplier);
	}
	
	public Vector substract(Vector v2){
		return new Vector(this.x-v2.getX(), this.y-v2.getY());
	}
	
	public double ScalarProduct(Vector v2){
		return (this.x*v2.getX()+this.y*v2.getY());
	}
	
	public double length(){
		return Math.sqrt(Math.pow(this.x, 2)+Math.pow(this.y, 2));
	}
	
	public double angle(Vector v2){
		return Math.toDegrees(Math.acos(this.ScalarProduct(v2)/(this.length()*v2.length())));
	}
}
